﻿using WH.Contracts.Systems.Users;
using WH.Model.Systems;
using WH.Services.BaseService;
using Rw.Core.Common;
using Rw.Core.Common.Paging;
using WH.Common.Paging;
using System.Linq.Expressions;

namespace WH.Services.IServices.ISystem
{
    public interface IUserService : IBaseService<UserEntity>
    {
        /// <summary>
        /// 校验用户名密码
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="passWord"></param>
        /// <returns></returns>
        Task<ResultResponse<UserEntity>> CheckLoginAsync(string userName, string passWord);

        /// <summary>
        /// 校验用户名密码
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="passWord"></param>
        /// <returns></returns>
        Task<UserEntity> GetUser(string id);

        /// <summary>
        /// 登录次数加1
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<int> AddLogonCount(UserEntity entity);

        /// <summary>
        /// 验证账号是否存在
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        Task<bool> ExistsUserAsync(string? account);

        /// <summary>
        /// 判断是否存在满足条件的实体
        /// </summary>
        /// <param name="predicate">条件谓词</param>
        /// <returns>是否存在</returns>
        Task<bool> ExistsNoFilterAsync(Expression<Func<UserEntity, bool>> predicate);

        /// <summary>
        /// 登录统计
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<int> GetLogonCountAsync();

        Task<IPagedList<UserEntity>> GetUsersByPageAsync(PageParam pager, UserFilter filter);
    }
}
